﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="Login" %>

<%@ Register Src="Script/SubScript.ascx" TagName="SubScript" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>登录</title>
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">

    <uc1:SubScript ID="SubScript1" runat="server" />
    <style type="text/css">
        html
        {
            overflow: hidden;
            border: 0px;
        }
        
        body
        {
            padding: 0px;
            margin: 0px;
            border: 0px;
        }
        .div_bk
        {
            background: url("images/loginpanel.jpg" ) repeat-x;
            width: 385px;
            height: 230px;
        }
        .div_logo
        {
            background: url("images/lognew.jpg" ) no-repeat;
            width: 381px;
            height: 68px;
        }
        #txtUser, #txtuser_reg, #txtemail_reg, #txtnick_reg
        {
            position: absolute;
            font-size: 12px;
            padding: 1px;
            font-family: Courier New;
            border: solid 1px #7F9DB9;
        }
        #txtpwd, #txtpwd_reg, #txtpwd_confirm_reg
        {
            position: absolute;
            font-size: 14px;
            padding: 1px;
            font-family: 宋体;
            border: solid 1px #7F9DB9;
        }
        label
        {
            font-size: 12px;
            font-family: 宋体;
        }
        #login, #register
        {

        }
        .loginbtn
        {
        	padding-top:-2px;
        	 background-image:url("images/btn_normal.png");
        	 background-repeat:no-repeat;
        	}
        .link
        {
            font-family: 宋体;
            font-size: 12px;
            position: absolute;
            color: #229ACD;
            cursor: pointer;
            text-align: right;
            text-decoration: none;
        }
        .link:hover
        {
            text-decoration: underline;
        }
    </style>
    <script language="javascript" type="text/javascript">

        document.onkeydown = function () {
            if (event.keyCode == 116 || (event.ctrlKey && event.keyCode == 82)) {
                event.keyCode = 0;
                event.returnValue = false;
                return false;
            }
            if (event.keyCode == 70 && event.ctrlKey && !event.altKey && !event.shiftKey) {
                event.keyCode = 0;
                event.returnValue = false;
                return false;
            }

        }
    </script>
    <script language="javascript" type="text/javascript">
        function init() {
            //document.getElementById("download_link").style.display = ClientMode ? "none" : "block";

            try {
                document.getElementById("txtUser").focus();
            }
            catch (ex) {
            }

            if (Core.Params["name"] != undefined) {
                document.getElementById("txtUser").readOnly = true;
                document.getElementById("txtUser").value = Core.Params["name"];
                document.getElementById("txtpwd").focus();
            }

            var cookie = getCookie("bjzwtPw");
            if (cookie != undefined && cookie != "") {
                document.getElementById("txtUser").value = cookie.split("$$")[0];
                document.getElementById("txtpwd").value = cookie.split("$$")[1];
                document.getElementById("ckSavePw").checked = true;
            }

            var s = document.getElementById("status").value;
            if (s == "login") {
                CurrentWindow.Completed();
                Core.OutputPanel.MoveEx("", 10000, 10000, true);
                Core.OutputPanel.Show();

                Core.OutputPanel.Load(
				Core.GetPageUrl("Output.aspx"),
				function () {
				    Core.OutputPanel.Hide();

				    if (!ClientMode) {
				        //Core.OutputPanel.MoveEx("",0,0,true);
				        //Core.OutputPanel.Show();
				    }

				    var login_data = Core.Utility.ParseJson(document.getElementById("data").value);

				    Core.Session.InitService(
						login_data.UserInfo.Name,
						login_data.UserInfo,
						document.cookie,
						document.getElementById("sessionId").value
					);
				    Core.Taskbar.Show();
				    Core.Session.GetGlobal("SingletonForm").ShowFriendForm();
				    CurrentWindow.Close();
				}
			);
            }
            else if (s == "error") {
                CurrentWindow.Completed();
                Core.Utility.ShowError(document.getElementById("data").value);
            }
        }

        function login_onclick() {
            var s = document.getElementById("txtUser").value;
            if (s == "") {
                Core.Utility.ShowWarning("请输入用户名!");
                return false;
            }
            return true;
        }

        function ShowLoginPage() {
            document.getElementById("div_reg").style.display = "none";
            document.getElementById("div_login").style.display = "block";
        }

        function ShowRegPage() {
            document.getElementById("div_reg").style.display = "block";
            document.getElementById("div_login").style.display = "none";
        }

        function match(reg, str) {
            reg.lastIndex = 0;
            var ft = reg.exec(str);
            return (ft != null && ft.length == 1 && ft[0] == str)
        }

        function register_onclick() {
            var nameReg = /[a-zA-Z0-9_]+/ig;
            var pwdReg = /[a-zA-Z0-9]+/ig;

            if (document.getElementById("txtuser_reg").value == "") {
                Core.Utility.ShowWarning("请输入用户名!");
                return false;
            }

            if (!match(nameReg, document.getElementById("txtuser_reg").value)) {
                Core.Utility.ShowWarning("用户名格式不正确（用户名只能包含英文字符，数字和下划线）！");
                return false;
            }

            if (document.getElementById("txtuser_reg").value.length < 4) {
                Core.Utility.ShowWarning("用户名必须4个字符以上！");
                return false;
            }

            if (document.getElementById("txtnick_reg").value == "") {
                Core.Utility.ShowWarning("请输入昵称!");
                return false;
            }

            if (document.getElementById("txtpwd_reg").value == "") {
                Core.Utility.ShowWarning("请输入密码!");
                return false;
            }

            if (!match(pwdReg, document.getElementById("txtpwd_reg").value)) {
                Core.Utility.ShowWarning("密码格式不正确（密码只能包含英文字符和数字）！");
                return false;
            }

            if (document.getElementById("txtpwd_reg").value.length < 6) {
                Core.Utility.ShowWarning("密码必须6个字符以上！");
                return false;
            }

            if (document.getElementById("txtpwd_confirm_reg").value != document.getElementById("txtpwd_reg").value) {
                Core.Utility.ShowWarning("两次输入密码不一致!");
                return false;
            }

            if (document.getElementById("txtemail_reg").value == "") {
                Core.Utility.ShowWarning("请输入电子邮箱!");
                return false;
            }

            return true;
        }
        function form1_onsubmit() {
         
            var ck = document.getElementById("ckSavePw");
            if (ck.checked) {
                var values = document.getElementById("txtUser").value + "$$" + document.getElementById("txtpwd").value;
                var cookie = getCookie("bjzwtPw");
                if (cookie != undefined && cookie != "" && cookie != values) {
                    delCookie("bjzwtPw");
                }
                SetCookie("bjzwtPw", values);
            }
            else {
                var cookie = getCookie("bjzwtPw");
                if (cookie != undefined && cookie != "") {
                    delCookie("bjzwtPw");
                }
            }
            CurrentWindow.Waiting("");
            return true;
        }

        function SetCookie(name, value)//两个参数，一个是cookie的名子，一个是值
        {
            var Days = 30000; //此 cookie 将被保存 30*1000 天
            var exp = new Date();    //new Date("December 31, 9998");
            exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
            document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
        }
        function getCookie(name)//取cookies函数        
        {
            var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
            if (arr != null) return unescape(arr[2]); return null;

        }
        function delCookie(name)//删除cookie
        {
            var exp = new Date();
            exp.setTime(exp.getTime() - 1);
            var cval = getCookie(name);
            if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
        }

    </script>
</head>
<body>
    <form id="form1" runat="server" onsubmit="return form1_onsubmit();">
    <div id="div_login" class="div_bk">
        <div class="div_logo">
        </div>
        <label for="txtUser" 
            style="position: absolute; top: 87px; left: 28px; text-align: right;">
            账号：
        </label>
        <input id="txtUser" name="txtuser" runat="server" type="text" style="top: 75px;
            left: 75px; width: 230px; height: 20px; margin-top: 4px;" />
        <label for="txtpwd" 
            style="position: absolute; top: 115px; left: 27px; text-align: right;">
            密码：
        </label>
        <input id="txtpwd" name="txtpwd" runat="server" type="password" style="top: 108px;
            left: 75px; width: 230px; height: 20px;" />
        <input id="ckSavePw" type="checkbox" 
            style="position: absolute; top: 146px; left: 165px;" />
        <label for="ckSavePw" 
            style="position: absolute; top: 151px; left: 191px; text-align: right;">
            记住密码
        </label>
        <%--	<a class="link" id="download_link" href="client-1.1.0.11.zip" style="top: 240px; left: 355px; width: 65px; height: 14px;">下载桌面版</a>--%>
        <%--	<a class="link" href="javascript:ShowRegPage();" style="top: 240px; left: 425px; width: 65px; height: 14px;">注册新账户</a>--%>
        <input id="login" name="login" type="submit" value="登 录" class="loginbtn"  style="position: absolute;
            top: 145px; left: 85px; height: 20px; width: 73px;" 
            onclick="return login_onclick()" />
            <label for="company" 
            style="position: absolute; top: 202px; left: 54px; text-align: center; padding-top:4px">
            <b>技术支持：中城泰信(北京)信息技术有限公司</b>
            </label>
    </div>
    <div id="div_reg" class="div_bk" style="display: none">
        <div class="div_logo">
        </div>
        <label for="txtuser_reg" style="position: absolute; top: 106px; left: 171px; text-align: right;">
            用户名：
        </label>
        <input id="txtuser_reg" name="txtuser_reg" runat="server" type="text" style="top: 100px;
            left: 229px; width: 258px; height: 14px;" />
        <label for="txtnick_reg" style="position: absolute; top: 146px; left: 171px; text-align: right;">
            昵&nbsp;&nbsp;称：
        </label>
        <input id="txtnick_reg" name="txtnick_reg" runat="server" type="text" style="top: 140px;
            left: 229px; width: 258px; height: 14px;" />
        <label for="txtpwd_reg" style="position: absolute; top: 186px; left: 160px; text-align: right;">
            登录密码：
        </label>
        <input id="txtpwd_reg" name="txtpwd_reg" runat="server" type="password" style="top: 180px;
            left: 229px; width: 258px; height: 14px;" />
        <label for="txtpwd_confirm_reg" style="position: absolute; top: 226px; left: 160px;
            text-align: right;">
            密码确认：
        </label>
        <input id="txtpwd_confirm_reg" name="txtpwd_confirm_reg" runat="server" type="password"
            style="top: 220px; left: 229px; width: 258px; height: 14px;" />
        <label for="txtemail_reg" style="position: absolute; top: 266px; left: 160px; text-align: right;">
            电子邮件：
        </label>
        <input id="txtemail_reg" name="txtemail_reg" runat="server" type="text" style="top: 260px;
            left: 229px; width: 258px; height: 14px;" />
        <a class="link" href="javascript:ShowLoginPage();" style="top: 320px; left: 410px;
            width: 80px; height: 14px;">返回登录页面</a>
        <input id="register" name="register" type="submit" value="注 册" style="position: absolute;
            top: 367px; left: 521px; height: 26px; width: 67px;" onclick="return register_onclick()" />
    </div>
    <input id="status" name="status" runat="server" type="hidden" value="none" />
    <input id="data" name="data" runat="server" type="hidden" value="" />
    <input id="sessionId" name="sessionId" runat="server" type="hidden" value="" />
    </form>
</body>
</html>
